﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using RM.WebClient.RMServices;

namespace RM.WebClient
{
    public partial class QuestionBank : Page
    {
        public QuestionBank()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(QuestionBank_Loaded);
        }

        void QuestionBank_Loaded(object sender, RoutedEventArgs e)
        {
            QuestionServiceClient questionservice = new QuestionServiceClient();
            questionservice.Question_GetAllCompleted += new EventHandler<Question_GetAllCompletedEventArgs>(questionservice_GetAllCompleted);
            questionservice.Question_GetAllAsync();
        }

        void questionservice_GetAllCompleted(object sender, Question_GetAllCompletedEventArgs e)
        {
            dataGrid.DataContext = e.Result;
            lblWait.Visibility = Visibility.Collapsed;
            progressBar.Visibility = Visibility.Collapsed;

        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {

        }

        private void autoCompleteQuestionSearch_TextChanged(object sender, RoutedEventArgs e)
        {

        }

        private void imgAddQuestion_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void Link_QuestionDetail_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("AddEditQuestion", UriKind.Relative));
        }

        private void Edit_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Question question=dataGrid.SelectedItem as Question;
            NavigationService.Navigate(new Uri("AddEditQuestion/" + question.Id , UriKind.Relative));
        }

    }
}
